package adata;

import java.util.LinkedList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.RowSet;
import javax.sql.rowset.CachedRowSet;

import model.ApplicationModel;
import model.ReviewerModel;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbException;
import forms.ApplicantForm;
import forms.Degree;

public class ApplicationsPageAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws DbException {
			
		
		RowSet crsAppPage = null;
		
        if (request.getParameter("specialization") != null)  {
        	crsAppPage = ApplicationModel.getSpecAppPage(request.getParameter("specialization"));
        }
        else if (request.getParameter("discipline") != null)  {
        	crsAppPage = ApplicationModel.getDiscAppPage(request.getParameter("discipline"));
        }
        else if ( (request.getParameter("reviewer") != null) && (request.getParameter("graded").equals("true")) ){
        	crsAppPage = ReviewerModel.getAppGraded(request.getParameter("reviewer"));
        }else if ( (request.getParameter("reviewer") != null) && (request.getParameter("graded").equals("false")) ){
        	crsAppPage = ReviewerModel.getAppUngraded(request.getParameter("reviewer"));
        }
	

		request.setAttribute("crsAppPage", crsAppPage);
		
		
		return mapping.findForward("success");
		
	}
}